package com.bit101.components
{
	import flash.display.Bitmap;
	import flash.display.DisplayObjectContainer;
	import flash.display.Sprite;
	import flash.events.MouseEvent;
	import flash.filters.DropShadowFilter;
	import flash.text.TextField;
	
	public class ImageEmbedButton extends Sprite
	{
		private var drop:DropShadowFilter = new DropShadowFilter(10,45,0,0.5);
		private var txt:TextField;
		public function ImageEmbedButton(parent:DisplayObjectContainer=null, xpos:Number=0, ypos:Number=0,source:Class=null,defaultHandler:Function = null)
		{
			var img:Bitmap = new source;
			addChild(img);
			this.width = img.width;
			this.height = img.height;
			parent.addChild(this);
			this.x = xpos;
			this.y = ypos;
			this.addEventListener(MouseEvent.ROLL_OVER,onMouseOver);
			this.addEventListener(MouseEvent.ROLL_OUT,onMouseOut);
			if(defaultHandler != null)
			{
				addEventListener(MouseEvent.CLICK, defaultHandler);
			}
		}
		private function onMouseOver(event:MouseEvent):void{
			this.y --;
			//this.filters = [drop]
		}
		private function onMouseOut(event:MouseEvent):void{
			this.y ++;
			this.filters = null;
		}
		public function setLabel(str:String,color:String):void{
			if(txt == null){
				txt = new TextField;
			}
			txt.width = 120;
			txt.height = 50;
			txt.y = 6;
			txt.selectable = false;
			this.addChild(txt);
			txt.htmlText = "<p align='center'><font face='微软雅黑' color='" + color + "' size='18'><b>"+ str +"</b></font></p>";
		}
	}
}